package org.springcloud.wisdom.spring_01_canteen.dishes.cart;

import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;

@NoArgsConstructor
@AllArgsConstructor
@Data
@TableName("wisdom.cart")
public class Cart {
    // 主键
    @TableId(type = IdType.AUTO)
    private Integer id;
    // 菜名
    @TableField("dname")
    private String dname;
    // 单价
    @TableField("price")
    private Double price;
    // 总价
    private Double totalprice;
    // 数量
    @TableField("count")
    private Integer count;
    // 计算总价的方法
    public void calculateTotalPrice() {
        this.totalprice = this.price * this.count;
    }
    // 重置总价的方法
    public void resetTotalPrice() {
        this.totalprice = null;
    }
}